package org.myspringframework.mvc.render;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.myspringframework.mvc.RequestProcessorChain;

import javax.servlet.http.HttpServletResponse;

/**
 * org.myspringframework.mvc.render <br>
 * 资源404使用的渲染器
 *
 * @author jaymin
 * @since 2021/5/22
 */
@AllArgsConstructor
@NoArgsConstructor
public class ResourceNotFoundResultRender implements ResultRender {
    private String httpRequestMethod;
    private String httpPath;

    @Override
    public void render(RequestProcessorChain requestProcessorChain) throws Exception {
        HttpServletResponse httpServletResponse = requestProcessorChain.getHttpServletResponse();
        httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "获取不到对应的请求资源:请求路径:[" +
                httpPath + "]" + "请求方法[" + httpRequestMethod + "]");
    }
}
